package com.wk.design.adapter;

/**
 * 电源适配器
 * 将已存在的类转换成期望的接口
 */
public class PowerAdapter implements Dc5{
    private Ac220 ac220;
    public PowerAdapter(Ac220 ac220) {
        this.ac220 = ac220;
    }

    @Override
    public int output5() {
        int ac = ac220.output220();
        int dc = ac/44;
        System.out.println("使用适配器转换"+dc+"电压");
        return dc;
    }

    public static void main(String[] args) {
        Ac220 ac220 = new Ac220();
        PowerAdapter powerAdapter = new PowerAdapter(ac220);
        int power = powerAdapter.output5();
        System.out.println(power);
    }
}
